<template>
  <el-form :model="form" inline>
    <el-form-item label="用户名">
      <el-input 
        v-model="form.username" 
        placeholder="请输入用户名" 
        clearable 
        @keyup.enter="handleSearch"
      />
    </el-form-item>
    
    <el-form-item label="时间范围">
      <el-date-picker
        v-model="form.timeRange"
        type="daterange"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        value-format="YYYY-MM-DD"
      />
    </el-form-item>
    
    <el-form-item>
      <el-button type="primary" @click="handleSearch" :icon="Search">搜索</el-button>
      <el-button @click="handleReset" :icon="Refresh">重置</el-button>
    </el-form-item>
  </el-form>
</template>

<script setup>
import { reactive } from 'vue'
import { Search, Refresh } from '@element-plus/icons-vue'

const emit = defineEmits(['search'])

// 表单数据
const form = reactive({
  username: '',
  timeRange: []
})

// 处理搜索
const handleSearch = () => {
  emit('search', {
    username: form.username.trim(),
    startTime: form.timeRange?.[0] || '',
    endTime: form.timeRange?.[1] || ''
  })
}

// 重置表单
const handleReset = () => {
  form.username = ''
  form.timeRange = []
  handleSearch()
}
</script>

<style scoped>
.el-form {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.el-form-item {
  margin-bottom: 0;
  margin-right: 0;
}

.el-form-item :deep(.el-form-item__label) {
  color: #ffffff !important;
  font-weight: 500 !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
}

.el-input {
  width: 200px;
  transition: all 0.3s ease;
}

.el-input:hover {
  box-shadow: 0 0 0 1px rgba(0, 212, 255, 0.5) !important;
}



.el-date-editor {
  width: 280px;
}

/* 引用对话统计分析模块的时间范围样式 */
:deep(.el-input__wrapper) {
  background: linear-gradient(135deg, rgba(0, 20, 40, 0.8) 0%, rgba(0, 40, 80, 0.8) 100%) !important;
  border: 1px solid rgba(0, 212, 255, 0.3) !important;
  border-radius: 8px !important;
  backdrop-filter: blur(10px);
}

:deep(.el-input__wrapper:hover) {
  border-color: rgba(0, 212, 255, 0.5) !important;
}

:deep(.el-input__wrapper.is-focus) {
  border-color: rgba(0, 212, 255, 0.6) !important;
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.2) !important;
}

:deep(.el-input__inner) {
  color: #ffffff !important;
  background: transparent !important;
  font-weight: 500 !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
}

:deep(.el-input__inner::placeholder) {
  color: rgba(255, 255, 255, 0.6) !important;
}

/* el-date-picker 下拉面板样式 */
:deep(.el-picker-panel) {
  background: linear-gradient(135deg, rgba(0, 20, 40, 0.95) 0%, rgba(0, 40, 80, 0.95) 100%) !important;
  border: 1px solid rgba(0, 212, 255, 0.4) !important;
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3) !important;
  backdrop-filter: blur(20px);
}

:deep(.el-picker-panel .el-date-table th) {
  color: #ffffff !important;
  font-weight: 500 !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5) !important;
}

:deep(.el-picker-panel .el-date-table td .el-date-table__cell) {
  color: #ffffff !important;
  background: transparent !important;
}

:deep(.el-picker-panel .el-date-table td .el-date-table__cell:hover) {
  background: rgba(0, 212, 255, 0.2) !important;
  color: #ffffff !important;
}

:deep(.el-picker-panel .el-date-table td .el-date-table__cell.current) {
  background: rgba(0, 212, 255, 0.3) !important;
  color: #ffffff !important;
}

/* 引用对话统计分析模块的按钮样式 */
:deep(.el-button) {
  background: rgba(0, 212, 255, 0.25) !important;
  border: 1px solid rgba(0, 212, 255, 0.4) !important;
  color: #ffffff !important;
  border-radius: 8px !important;
  backdrop-filter: blur(10px);
  font-weight: 500 !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
}

:deep(.el-button:hover) {
  background: linear-gradient(135deg, rgba(0, 20, 40, 0.9) 0%, rgba(0, 40, 80, 0.9) 100%) !important;
  border-color: rgba(0, 212, 255, 0.5) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.2) !important;
}

:deep(.el-button--primary) {
  background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%) !important;
  border: none !important;
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3) !important;
}

:deep(.el-button--primary:hover) {
  background: linear-gradient(135deg, #0099cc 0%, #0077a3 100%) !important;
  box-shadow: 0 6px 16px rgba(0, 212, 255, 0.4) !important;
}

@media (max-width: 768px) {
  .el-form {
    gap: 12px;
  }
  
  .el-input {
    width: 160px;
  }
  
  .el-date-editor {
    width: 240px;
  }
}
</style>